package cn.tedu.security.service;

import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.core.userdetails.User;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service;


public class UserDetailServiceImpl implements UserDetailsService {
    private static final String PASSWORD =
            "$2a$10$PCNgCswCM9wTRtpD8vVJkuK8ReYk/obXwSn5t7w2AK/WKBFSEPgXi";//123456
    @Override
    public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
        System.out.println("username="+username);
        //....
        return User.withUsername(username)
                .password(PASSWORD)//密码来自数据库(基于用户名查询出来的密码)
                .authorities("sys:private:view","sys:private:edit")//权限来自数据库(基于用户名查询出来的权限)
                .build();
    }


}
